<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions">

	<style type="text/css">
.moduleRow {
	background-color: silver;
	font-weight: bold;
	background-image: none;
}
</style>
	<p:treeTable id="privilegeTable" value="#{privilegeTable.root}" var="rowData"
		rowStyleClass="#{rowData.module ? 'moduleRow' : null}">
		<f:facet name="header">
			<p:outputLabel value="C = Creation; R = Reading; U = Updating; D = Delete; E = Execution "></p:outputLabel>
		</f:facet>

		<p:column headerText="Function name">
			<h:outputText value="#{rowData.objectName}" />
		</p:column>

		<p:column headerText="C" style="width:5px; padding:3px; border: 2px; text-align: center;">
			<p:selectBooleanCheckbox value="#{rowData.create}" rendered="#{rowData.create != null}"
				onchange="checkAction(#{rowData.module}, #{rowData.objectId}, 'C', $(this).is(':checked'))" />
		</p:column>
		<p:column headerText="R" style="width:5px; padding:3px; border: 2px; text-align: center;">
			<p:selectBooleanCheckbox value="#{rowData.read}" rendered="#{rowData.read != null}"
				onchange="checkAction(#{rowData.module}, #{rowData.objectId}, 'R', $(this).is(':checked'))" />
		</p:column>
		<p:column headerText="U" style="width:5px; padding:3px; border: 2px; text-align: center;">
			<p:selectBooleanCheckbox value="#{rowData.update}" rendered="#{rowData.update != null}"
				onchange="checkAction(#{rowData.module}, #{rowData.objectId}, 'U', $(this).is(':checked'))" />
		</p:column>
		<p:column headerText="D" style="width:5px;  padding:3px; border: 2px; text-align: center;">
			<p:selectBooleanCheckbox value="#{rowData.delete}" rendered="#{rowData.delete != null}"
				onchange="checkAction(#{rowData.module}, #{rowData.objectId}, 'D', $(this).is(':checked'))" />
		</p:column>
		<p:column headerText="E" style="width:5px; padding:3px; border: 2px; text-align: center;">
			<p:selectBooleanCheckbox value="#{rowData.execute}" rendered="#{rowData.execute != null}"
				onchange="checkAction(#{rowData.module}, #{rowData.objectId}, 'E', $(this).is(':checked'))" />
		</p:column>
	</p:treeTable>
	<pe:remoteCommand name="checkAction" process="@this" update="privilegeTable"
		actionListener="#{privilegeTable.checkAction}">
		<pe:methodSignature parameters="java.lang.Boolean, java.lang.Long, java.lang.String, java.lang.Boolean" />
		<pe:methodParam name="isModule" />
		<pe:methodParam name="objectId" />
		<pe:methodParam name="mode" />
		<pe:methodParam name="checked" />
	</pe:remoteCommand>
</ui:composition>